<?php

function normaliseDate($thedate) {
    if (strlen($thedate) > 0) {
        $mydate = new DateTime($thedate);
        return $mydate->format("d-M-Y");
    }
    return "Not Set";
}

function normaliseDateTime($thedate) {
    if (strlen($thedate) > 0) {
        $mydate = new DateTime($thedate);
        return $mydate->format("d-M-Y H:i:s");
    }
    return "Not Set";
}

function substractYears($date1, $date2) {//must be DateTime objects, date1 is the bigger date
    $date1 = mktime($date1->format("H"), $date1->format("i"), $date1->format("s"), $date1->format("m"), $date1->format("d"), $date1->format("Y"));
    $date2 = mktime($date2->format("H"), $date2->format("i"), $date2->format("s"), $date2->format("m"), $date2->format("d"), $date2->format("Y"));
    $dateDiff = $date1 - $date2;
    $fullDays = $dateDiff / (60 * 60 * 24);
    return floor($fullDays / 365.25) + 1;
}

//modifying dates
//$start_date = $start_date->format("Y-m-d H:i:s"); //make it a string
//$last_date = new DateTime($start_date);
//$last_date->modify("+1 year");
//$end_date = $last_date->format("Y-m-d H:i:s");
?>